<?php
/**
 *@author sparkguo
 *@date 2017-09-22  dhl,ubi,cne,日本邮政物流交运
 */
defined('BASEPATH') OR exit('No direct script access allowed');
class Expressshipment extends CI_Controller {

	/**
	 * Index Page for this controller.
	 */
	function __construct(){
		parent::__construct();
		$this->load->model('Function_m','fun');
		$this->load->model('ExpressShipment_m','m');
		$this->pageSize =$this->config->item('pagenum');
	 }

	public function datalist($orderType=3)
	{
        $get_express_type=$this->input->get('orderType');
        if(!empty($get_express_type)){
            $orderType=$get_express_type;    
        }
		$nowpage = $_REQUEST["pageid"];
	    if ($nowpage == "")
            $nowpage = 1;
		$where = " and orderType =".$orderType;
		$isexe = $this->input->get('isexe');
		$this->tpl->assign("isexe",$isexe);
		if($isexe==3){
			$where.=" AND isexe = 0";
		}else{
			if(!$isexe){
			}else{
			$where.=" AND isexe = $isexe";
			}
		}
		$other = $this->input->get('other');
		if($other)
		{
			$where.=" AND (orderID = '".$other."' or mailNo = '".$other."')";
			$this->tpl->assign("other",$other);
		}

		$starttime = $this->input->get('starttime');
        $starttime=trim($starttime);
		if($starttime){
			$times = $starttime." 00:00:00";
			$where.=" AND (mailinstime >= '".strtotime($times)."')";
			$this->tpl->assign("starttime",$starttime);
		}
        

		$endtime = $this->input->get('endtime');
        $endtime=trim($endtime);
		if(!empty($endtime)){
			$times = $endtime." 23:59:59";
			$where.=" AND (mailinstime <= '".strtotime($times)."')";
			$this->tpl->assign("endtime",$endtime);
		}
		$statusst = $this->input->get('statusst');
        $statusst_arr=array(1=>'已支付',2=>'配货中',3=>'已发货');
		if($statusst)
		{
			if($statusst==1)
			{
				$status ='已支付';
			}
			if($statusst==2)
			{
				$status ='配货中';
			}
			if($statusst==3)
			{
				$status =3;
			}
			$where.=" AND statusst = '".$status."'";
			$this->tpl->assign("statusst",$statusst);
		}
		$list = $this->fun->getalllist('db_mabangorder',$where,$nowpage,$if_csv,$this->pageSize);
		foreach($list["list"] as $key=>$rs)
		{
			if($rs["mailinstime"])$list["list"][$key]["mailinstime"] = date("Y-m-d H:i:s",$rs["mailinstime"]);
            if($rs['statusst']==3){$list["list"][$key]["statusst"] ='已发货';}
            $order_sn[]=$rs['orderID']; 
		}
        /*if(count($order_sn)>0){
            $order_numberd_str = implode("','", $order_sn);
            $orderinfos = $this->db->get_where("db_order_list", "  order_sn in ('" . $order_numberd_str . "')")->result_array();
            $new_order=array();
            foreach($orderinfos as $orderkey=>$orderval){
                $new_order[$orderval['order_sn']]=$orderval;
            } 
        }*/
		$pageList = $this->pagenav->page($list["total"], $nowpage, $this->pageSize);
        $this->tpl->assign("totalpage", ceil($list["total"] / $this->pageSize));
		$this->tpl->assign("total", $list["total"]);
        $this->tpl->assign("pageList", $pageList);
		$this->tpl->assign("department", $_COOKIE["department"]);
		$this->tpl->assign("orderlist",$list["list"]);
        $express_type=array(1=>'顺丰',3=>'DHL',4=>"CNE",5=>'UBI',6=>'云图',7=>'燕文',8=>'EMS',10=>'日本邮政',12=>'佳成物流',14=>'中通快递');
         $action_url=array(1=>'顺丰',3=>'DHL',4=>"CNE",5=>'UBI',6=>'云图',7=>'燕文',8=>'EMS',10=>'YIDA',12=>'JIAC',14=>'ZTO');
        $this->tpl->assign('expressType',$express_type[$orderType]);
        $this->tpl->assign('action_url',$action_url[$orderType]);
		if($orderType==3){
			$this->tpl->assign("isdhlremote",$this->config->item('isdhlremote'));
		}else{
			$this->tpl->assign("isdhlremote",0);
		}

		$this->tpl->assign("orderType",$orderType);
	
		  $this->tpl->display("expressshipment/list.tpl");
	}
    
    //查交易号作废订单
    public function disableOrder(){
        $trade_id_str=trim($this->input->post('trade_id_str'),',');
        $op=$this->input->get('op');
        if(!empty($trade_id_str)){
            $trade_ids = explode(",", $trade_id_str);
            foreach($trade_ids as $orderkey=>$trade_id_str){
                $into=array("tradeid"=>$trade_id_str, "creater"=>$_COOKIE['username'],"createtime"=>date("Y-m-d H:i:s"));
                $shopinfo=$this->fun->getdatabasesdetail("db_order_disable","AND tradeid ='$trade_id_str'");
                if($shopinfo==null){
                    $insert_state=$this->db->insert("db_order_disable",$into);
                }
            }
        }
        $disable_trades=$this->db->get_where("db_order_disable", "is_action=0")->result_array();
        $trade_id_arr=array();
        foreach($disable_trades as $orderkey=>$tradeinfo){
            $trade_id_arr[$tradeinfo['tradeid']]=$tradeinfo['tradeid'];  
        } 
       if(count($trade_id_arr)>0){
           $trade_id_str = implode("','", $trade_id_arr);
	       $reslist = $this->db->get_where("db_order_list", "  tradeid in ('" . $trade_id_str . "')")->result_array();
           
            //标作废
            foreach ($reslist as $key => $rs) {
                if ($rs["order_status"] != 5) {
					$rerderID[] = $rs["order_id"];	//存返回的订单ID号
                    $this->db->update("db_order_list", array("order_status" =>6), "order_id=" . $rs["order_id"]);
                    $this->db->update("db_order_disable", array("is_action" =>1), "tradeid=" . $rs["tradeid"]);
                    $this->fun->goods_update_log($rs["order_id"], "预提交易号作废订单，修改状态为：作废", 3);    //日志
                    echo "更改交易号为".$rs['tradeid']."的订单状态：作废 ，成功<br />";
                }
                unset($trade_id_arr[$rs['tradeid']]);
            }
            echo "暂未找到其中交易号为".implode('，',$trade_id_arr)."的订单数据<br />";
       }
       echo "作废处理完成 ";
       echo "<a href='javascript:history.go(-1)'>返回上一页</a>";
    }

    public function ajaxbutton(){
		$op = $_REQUEST["op"];
		if($op=='printlabel')
		{
			$id = $this->input->get('id');
			//DHL,UBI,ONE,yida,jiac,打印标签
            if(in_array($this->input->get('orderType'),array(3,4,5,10,12,14))){
                $this->load->library('expresssend');
                $this->expresssend->printrOrderLabel();    
            }
		}
        if($op=='outexpressexcel'){
            $types = $this->input->get('types');
			$times = "2018-03-29 00:00:00";
			$endtime = date("Y-m-d")." 23:59:59";
			$isoutput = time();
			$orderlist = $this->fun->getdatabaseslist('db_order_batchexpress'," AND batch_shipping_name='".$types."'
             AND opertime >='".$times."' and opertime <='".$endtime."' AND is_output=0");
             //dump($orderlist);
             if(count($orderlist)>0){
                 $order_sn_arr=iarray_column($orderlist,'batch_order_sn');
                 $order_sn_str=implode("','",$order_sn_arr);
                 $goodslist=$this->fun->getdatabaseslist('db_order_list,db_order_sell'," AND db_order_list.order_id=db_order_sell.order_id
                 AND db_order_list.order_sn in('".$order_sn_str."')","order_sn,goods_id");

                 $orders_goodsid=iarray_column($goodslist,"goods_id","order_sn");//orderofgoodid
                 $goods_id_arr=implode(",",$orders_goodsid);
                 $goods_name_list=$this->fun->getdatabaseslist('db_goods,db_goods_category'," AND db_goods.g_secondclassid=db_goods_category.id
                 AND db_goods.goods_id in(".$goods_id_arr.")","cate_name,goods_id");//
                 $cate_namelist=iarray_column($goods_name_list,"cate_name","goods_id");//goodsidcatename
             }
             
             //echo $this->db->last_query();
			$headers =array("运单号","品名","发货日期：(".date("Y-m-d").")");
			$listdata = "";
            // $bigname = $this->fun->getdatabasesdetail('db_goods_category', " AND id = '" . $goods["g_secondclassid"] . "'");
			foreach($orderlist as $key=>$rs)
			{
			     $goods_catname=$cate_namelist[$orders_goodsid[$rs['batch_order_sn']]];
                 $goods_catname=$goods_catname==''?'服装':$goods_catname;
                 $goods_catname=$goods_catname=='箱包'?'包':$goods_catname;
                 $goods_catname=$goods_catname=='箱包'?'包':$goods_catname;
                 $goods_catname=$goods_catname=='其他周边'?'服饰配件':$goods_catname;
				//$rsdb = $this->db->get_one("SELECT * from db_mabangorder where orderID='".$rs['batch_order_sn']."' AND orderType=2 and isexe=1");
				$listdata[$key][] = $rs['batch_shipping_number'];
				$listdata[$key][] = $goods_catname."1件";
				$this->db->update('db_order_batchexpress',array("is_output"=>$isoutput)," id=".$rs['id']);
                //echo $this->db->last_query();
			}
            //dump($listdata);
			$this->fun->ouputexclePro($headers,$listdata);
		}
        if($op=='setWrongFlag'){
            $expdataid = $_REQUEST["id"];
            $flag = $_REQUEST["flag"];
            $res = $this->fun->getdatabasesdetail("db_mabangorder"," AND id = ".$expdataid);
            $flag=$res['haveWrong']==1?0:1;
            $this->db->update("db_mabangorder", array("haveWrong" =>$flag), "id=".$expdataid); 
            $res = array("result" => 200, "have_wrong" => $flag,'msg'=>'success');
            echo json_encode($res);    
        }
        if($op=='setShipmentState'){//设置配货中
            $this->setShipmentState();
        }
        //删除交运重新处理
        if($op=='delShipment'){
             $res = $this->db->select()->from('db_mabangorder')->where('id=' . $this->input->post('id'))->get()->result_array();
            $this->db->delete('db_mabangorder', 'id=' . $this->input->post('id'));
            $this->db->delete('db_mabangsell', 'orderid=' . $res[0]["orderID"]);
            $res = array("txt" => 200, "url" => '/order/sfexpress');
            echo json_encode($res);
            die;          
        }
        //返回相关交运配置
        if($op == 'getExpressConf'){
            $res = $this->fun->getdatabasesdetail("web_config"," AND c_key = '".$this->input->post_get("ckey")."'");
            //echo $this->db->last_query();exit;
            if($res["c_value"]){
                $arr_c_value = unserialize($res["c_value"]);
                echo json_encode($arr_c_value);
                exit;
            }else{
            }
        }
        
        if($op == 'setExpressConf'){
            $post["user_id"]  = $this->input->post("user_id");
            $post["pass"]  = $this->input->post("pass");
            $post["api_url"]  = $this->input->post("api_url");
            $arr_data = array('searialize'=>serialize($post));
            echo json_encode($arr_data);
            exit;
        }
        
		//ubi交运
		if($op =='UBIexpress'){	
			$orderlist = trim($this->input->post('orderlist'));
			//如果获取到的订单来源为马帮
			if($this->input->post('isformMabang') ==1)
			{
				$this->load->library('Mabang');
				$res= $this->mabang->savemabangorderlist($orderlist,5);
			}
			if($orderlist!=''){//有运单号
				if(dhtml($_POST['course']=='express_send')){
					$order_sn_list = explode("\n",trim($orderlist));
					foreach($order_sn_list as $key=>$sn){
					    $sn=str_replace("\\r",'',$sn);
						$order_sn_str.=trim($sn).",";  
					}
					$_POST['orderlist']=$order_sn_str;
				}
				$res = $this->m->saveexpress();
			}
			$string_note= '开始处理订单的交运...<br />'; 
			echo $string_note;
			echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=shipmentOrder&pageid=1&express_type=UBI\">";   
			//echo '<iframe id="mainFrame" name="mainFrame" scrolling="auto" src="/expressshipment/shipmentOrder?pageid=1&express_type=UBI" frameborder="2" style="padding: 0px; width: 100%; height:1000px;"></iframe>';
			 //$this->tpl->display("order/shipmentOrder.tpl");
			
		}
		if($op=="DHLexpress")
		{
		
			 $orderlist = trim($this->input->post('orderlist'));
			if($orderlist!=''){//有运单号
				if($_POST['course']=='express_send'){
					$order_sn_list = explode("\n",trim($orderlist));
					foreach($order_sn_list as $key=>$sn){
					    $sn=str_replace("\\r",'',$sn); 
						$order_sn_str.=trim($sn).",";  
					}
					$_POST['orderlist']=$order_sn_str;
				}
				
				$res = $this->m->saveexpress();
			}
			
			
			if($this->config->item('isdhlremote')==1)
			{
				echo "请点击右上角，远程交运！远程交运完成之后！点击获取运单信息";
				die;
				/*
				$string_note= '使用远程交运DHL订单...等待下方出现执行完成之后，<font color=red><a href="/expressshipment/ajaxbutton?op=GetOverDHLexpress">点击此处获取所有运单信息</a></font><br />';
				echo $string_note;
				echo '<iframe id="mainFrame" name="mainFrame" scrolling="auto" src="http://47.88.102.159/shipmentOrder.php" frameborder="2" style="padding: 0px; width: 100%; height:1000px;"></iframe>';
				*/
			}else{
				$string_note= '开始处理订单的交运...<br />';
				echo $string_note;
				echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=shipmentOrder&pageid=1&express_type=DHL\">";  
			}
			
		}
        
		if($op=="CNEexpress")
		{
            $orderlist = trim($this->input->post('orderlist'));
    		if($orderlist!=''){//有运单号
                if(dhtml($_POST['course']=='express_send')){
                    $order_sn_list = explode("\n",trim($orderlist));
                    foreach($order_sn_list as $key=>$sn){
                        $sn=str_replace("\\r",'',$sn);
                        $order_sn_str.=trim($sn).",";  
                    }
                    $_POST['orderlist']=$order_sn_str;
                }
                $res = $this->m->saveexpress();
    		}
			$string_note= '开始处理订单的交运...<br />'; 
			echo $string_note;
			echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=shipmentOrder&pageid=1&express_type=CNE\">";     
		}
		if($op=="YIDAexpress"){
            $orderlist = trim($this->input->post('orderlist'));
    		if($orderlist!=''){//有运单号
                if(dhtml($_POST['course']=='express_send')){
                    $order_sn_list = explode("\n",trim($orderlist));
                    foreach($order_sn_list as $key=>$sn){
                        $sn=str_replace("\\r",'',$sn);
                        $order_sn_str.=trim($sn).",";  
                    }
                    $_POST['orderlist']=$order_sn_str;
                }
                $res = $this->m->saveexpress();
    		}
			echo '开始处理订单的交运...<br />'; 
			echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=shipmentOrder&pageid=1&express_type=YIDA\">";     
		}
        if($op=="JIACexpress"){
            $orderlist = trim($this->input->post('orderlist'));
    		if($orderlist!=''){//有运单号
                if(dhtml($_POST['course']=='express_send')){
                    $order_sn_list = explode("\n",trim($orderlist));
                    foreach($order_sn_list as $key=>$sn){
                        $sn=str_replace("\\r",'',$sn);
                        $order_sn_str.=trim($sn).",";  
                    }
                    $_POST['orderlist']=$order_sn_str;
                }
                $res = $this->m->saveexpress();
    		}
			echo '开始处理订单的交运...<br />'; 
			echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=shipmentOrder&pageid=1&express_type=JIAC\">";     
		}
		if($op=='GetOverDHLexpress')
		{
			$this->load->library('Expresssend');                     
       		 $back=$this->expresssend->GetOverDHLexpresslist(); 
			 if($back)
			{
				echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=GetOverDHLexpress\">";  
			 }else{
				echo "交运完成";
				echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/datalist\">";  
			 }
		}
        if($op=='ZTOexpress'){
            $orderlist = trim($this->input->post('orderlist'));
    		if($orderlist!=''){//有运单号
                if(dhtml($_POST['course']=='express_send')){
                    $order_sn_list = explode("\n",trim($orderlist));
                    foreach($order_sn_list as $key=>$sn){
                        $sn=str_replace("\\r",'',$sn);
                        $order_sn_str.=trim($sn).",";  
                    }
                    $_POST['orderlist']=$order_sn_str;    
                }
                //$this->getTaobaoDeliveryInfo($_POST['orderlist']);//存储真实收货信息
                $res = $this->m->saveexpress();
    		}
			echo '开始处理订单的交运...<br />'; 
			echo "<meta http-equiv=\"refresh\" content=\"1; url=/expressshipment/ajaxbutton?op=shipmentOrder&pageid=1&express_type=ZTO\">";
        }
		if($op =='shipmentOrder')
		{
			
			$nowpage = $_REQUEST["pageid"];
            $success_data=$this->input->get('success');
			$express_type=$this->input->get_post('express_type');
			$express_type_arr=array('UPS'=>2,'DHL'=>3,'CNE'=>4,'UBI'=>5,'YT'=>6,'YW'=>7,'EMS'=>8,'YIDA'=>10,'JIAC'=>12,'ZTO'=>'14');
			$express_typeval=$express_type_arr[$express_type];
			$pageSize=1;
			switch($express_type){
				case "DHL":
					$pageSize=1;
					break; 
				case "UBI":
					$pageSize=1;
					break; 
				case "CNE": 
					$pageSize=1;
					break; 
				case "YIDA": 
					$pageSize=1;
					break;
                case "JIAC": 
					$pageSize=1;
					break;  
			}

				$where  = "(isexe = 0 ) AND orderType =$express_typeval";//or isexe = 2
				$this->db->where($where);
				$total = $this->db->count_all_results('db_mabangorder');
                $total+=$success_data;
                $success_data=$success_data==''?0:$success_data;
				if($nowpage*$pageSize>$total)
				{
				    if($express_type=="UBI" && $success_data>0){ //做预报功能
			            $this->load->library('Expresssend');
                        $express_arr=$this->fun->getalllist("db_mabangorder","AND isexe =1 AND orderType = $express_typeval",
                         1,0,$success_data," order by id desc",'id,mailNo,orderID');
                        $success_order_sn=array();
                        foreach($express_arr['list'] as $key=>$express_info){
                            $success_order_sn[]=$express_info['orderID'];
                        }
                        $back = $this->expresssend->sureUBIexpressOrder($success_order_sn); 
                        echo "订单:".$back."已预报<br />";
				    }
					echo "<br /><strong>所有订单交运完成！  <a href='/expressshipment/datalist/$express_typeval'>查看交运结果；</a></strong>";
                   
					die;
				}
                $start_row=$pageSize*$nowpage-$success_data-1;
                $start_row=$start_row<0?0:$start_row;
				$this->db->order_by('id', 'ASC');
				$listdb= $this->db->limit($pageSize,$start_row)
                ->get_where("db_mabangorder"," (isexe = 0) AND orderType = $express_typeval")->result_array();// or isexe = 2
				$list["total"] = $total;
				$list['list'] = $listdb;
                $shipmentinfo=$list['list'];
				
				//echo $this->db->last_query();
				$totalpage=ceil($list["total"] / $pageSize);//总页数;
				echo "总共：{$total}条，正在交运;$nowpage 条<br />"; 
                if((stripos($shipmentinfo[0]["customeraddress"],'PO Box')===0 or strlen($shipmentinfo[0]['customerid'])<=3) && $express_type=="DHL"){//have error
                    echo '订单'.$shipmentinfo[0]["orderID"].'交运失败，失败提示：';
                    if(strlen($shipmentinfo[0]['customerid'])<=3){
                        echo '收件人名称太过简短';
            			$exememo = "收件人名称太过简短";
                    }else{
                        echo '收货地址中的PO Box位置不够具体';
            			$exememo = "收货地址PO Box位置不够具体";
                    }
                    
        			$postdata["isexe"] = 2;
            		$postdata["exememo"] = $exememo;
            		$postdata["mailinstime"] =time();
            		$this->db->query($this->db->update_string('db_mabangorder', $postdata, 'id=' .$shipmentinfo[0]["id"]));
                    $back=array('success'=>0,'state'=>'finish');
                }else{
                    if($shipmentinfo[0]["mailNo"]!='' && $shipmentinfo[0]["isexe"]==1){
                        $postdata["isexe"] = 1; 
                        $this->db->query($this->db->update_string('db_mabangorder', $postdata, 'id=' .$shipmentinfo[0]["id"])); 
                        $back=array('state'=>'success','success'=>1); 
                    }else{
        				switch($express_type){
        					case "DHL":
        							$this->load->library('Expresssend');
        							$back = $this->expresssend->shipment($list['list']);    
        						break; 
        					case "UBI":
        							$this->load->library('Expresssend');
        							$back = $this->expresssend->shipmentUBI($list['list']); 
        						break; 
        					case "CNE":
        							$this->load->library('Expresssend');                            
        							$back=$this->expresssend->shipmentCNE($list['list']);    
        						break; 
        					case "YIDA": 
                                    $this->load->library('Expresssend');                     
        							$back=$this->expresssend->shipmentYIDA($list['list']);    
        						break; 
                            case "JIAC": 
                                    $this->load->library('Expresssend');                     
        							$back=$this->expresssend->shipmentJiAC($list['list']);    
        						break;
                            case "ZTO": 
                                    $this->load->library('Expresssend');                     
        							$back=$this->expresssend->shipmentZTO($list['list']);    
        						break;  
        				}
                    }
                }
				if($back['state']){
					$nowpage+=1;
                    $success_data+=$back['success'];
                    //echo 'not refersh';
					echo "<meta http-equiv=\"refresh\" content=\"2; url=/expressshipment/ajaxbutton?op=shipmentOrder&success=$success_data&pageid=$nowpage&express_type=$express_type\">";     
				}

		}

		if($op =='YIDAgettrack')
		{
			$this->load->library('Expresssend');                     
			$list = $this->db->select('order_id,shipping_number,shipping_time')->get_where("db_order_list","shopid in(SELECT id from d_shop where country = 2 and platfrom = 2) and is_update_platform = 2 ")->result_array();
			if(count($list)>0)
			{
				foreach($list as $key=>$rs)
				{
					if(time()-$rs['shipping_time'] > 86400)
					{
						$this->db->update('db_order_list',array('is_update_platform'=>3)," order_id = '".$rs['order_id']."'");
					}
					/*
					$tracking_number = $rs['shipping_number'];
					$back=$this->expresssend->getYIDAgettrack($tracking_number); 
					if($back ===true)
					{
						$this->db->update('db_order_list',array('is_update_platform'=>3)," order_id = '".$rs['order_id']."'");
					}*/
				}
				
			}
        	
		}
		
	}
   
    public function setShipmentState(){
        $id = trim($this->input->post('str'),",");
        $inid = explode(",",$id);
        foreach($inid as $key=>$order)
        {
           $rsdb = $this->fun->getdatabasesdetail('db_mabangorder'," AND id='".$order."'");
            if($rsdb["statusst"] =='已支付'){
                $postdata["statusst"] = '配货中';
                $orderdata['order_status'] = 3; //状态位配货中
                $this->db->update('db_mabangorder', $postdata, 'orderID=' ."'{$rsdb["orderID"]}'");
                $this->db->update('db_order_list', $orderdata, 'order_sn=' ."'{$rsdb["orderID"]}'");
            }
        }
            $res = array("ret" => 200, "msg" => 'success');
            echo json_encode($res);
        die;
    }


    //cne交运
    public function CNEexpress(){
        $orderlist = trim($this->input->post('orderlist'));
		if($orderlist!=''){//有运单号
            if(dhtml($_POST['course']=='express_send')){
                $order_sn_list = explode("\n",trim($orderlist));
                foreach($order_sn_list as $key=>$sn){
                    $sn=str_replace("\\r",'',$sn); 
                    $order_sn_str.=trim($sn).","; 
                    
                }
                $_POST['orderlist']=$order_sn_str;
            }
            $res = $this->m->saveexpress();
		}
        $this->load->library('Expresssend');  
        $this->expresssend->shipmentCNE($res);

    }
    

     
}
